<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * 费用管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_meye_merch_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as $item){
		$store=pdo_get('jy_meye_store',array('id'=>$item['store_id'],'uniacid'=>$_SESSION['uniacid']));
		$item['storename']=$store['title'];
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'提现列表'),
		),
		'list'=>array('data'=>'list','list'=>array(
			array('name'=>'storename','title'=>'商户名称','type'=>'string'),
			array('name'=>'price','title'=>'申请金额','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'string','options'=>'tixian_status'),
			array('name'=>'order_type','title'=>'订单类型','type'=>'radio','options'=>'order_type'),
			
		)),
		'search_one'=>array('name'=>'title'),
	);
	$return['htmls']=$htmls;
	$return['order_type']=$this->type__order();
	$return['tixian_status']=$this->type__tixian_status();
	exi($return);
}

if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_meye_merch_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		
	}else{
		$item=array();
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'tabs'=>array(
			array('op'=>'list','title'=>'返回列表'),
		),
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'string','title'=>'等级名称','name'=>'title','help'=>''),
					array('type'=>'text','title'=>'备注','name'=>'desc','help'=>''),
				)
			),
		)
	);
	
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$data=array(
		'title'=>trim($postdata['title']),
		'ops'=>trim($postdata['ops']),
		'desc'=>trim($postdata['desc']),
	);
	$id=intval($postdata['id']);
	if($id){
		pdo_update('jy_meye_merch_log',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		$data['store_id']=$store_id;
		pdo_insert('jy_meye_merch_log',$data);
	}
	exi('操作成功！','','list');
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_meye_merch_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}